﻿#ifndef TBUTASK_H
#define TBUTASK_H

#include "services/Task/ITask.h"
#include "utils/String/IntelHexParser.h"

class TBUTask : public ITask
{
    Q_OBJECT
public:
    enum {
        AppMode = 0x02,
        BootMode = 0x01,
    };
    explicit TBUTask(QObject *parent = nullptr);

    void setMemData(const QByteArray& block);

signals:
    void hasDone(int progress);

protected:
    void mcuReset();
    void enterBoot();
    bool isInMode(uint8_t mode);
    bool flash(MemBlock& block);

private:
    void runTask() override;
    QList<MemBlock> blockApp;
    QList<MemBlock> blockBoot;
};

#endif // TBUTASK_H
